//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#include "DisEMBLProcessResult.h"

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include <iostream>
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
using namespace std;
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
DisEMBLProcessResult::DisEMBLProcessResult() {
  
  this->id                    = new String ();
  this->sequence              = new String ();
    
  this->seqLoopCoils          = new String ();
  this->seqHotLoops           = new String ();
  this->seqRemarks465         = new String ();
    
  this->probLoopCoils         = new TListE <double> ();
  this->probHotLoops          = new TListE <double> ();
  this->probRemarks465        = new TListE <double> ();
  
  this->percentIDPLoopCoils   = 0;
  this->percentIDPHotLoops    = 0;
  this->percentIDPRemarks465  = 0;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
DisEMBLProcessResult::DisEMBLProcessResult(const DisEMBLProcessResult& disEMBLProcessResult) {
  
  this->id              = new String (disEMBLProcessResult.id);
  this->sequence        = new String (disEMBLProcessResult.sequence);
    
  this->seqLoopCoils    = new String (disEMBLProcessResult.seqLoopCoils);
  this->seqHotLoops     = new String (disEMBLProcessResult.seqHotLoops);
  this->seqRemarks465   = new String (disEMBLProcessResult.seqRemarks465);
    
  this->probLoopCoils   = new TListE <double> (disEMBLProcessResult.probLoopCoils);
  this->probHotLoops    = new TListE <double> (disEMBLProcessResult.probHotLoops);
  this->probRemarks465  = new TListE <double> (disEMBLProcessResult.probRemarks465);
  
  this->percentIDPLoopCoils   = 0;
  this->percentIDPHotLoops    = 0;
  this->percentIDPRemarks465  = 0;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
DisEMBLProcessResult::DisEMBLProcessResult(const DisEMBLProcessResult* disEMBLProcessResult) {
  
  this->id              = new String (disEMBLProcessResult->id);
  this->sequence        = new String (disEMBLProcessResult->sequence);
    
  this->seqLoopCoils    = new String (disEMBLProcessResult->seqLoopCoils);
  this->seqHotLoops     = new String (disEMBLProcessResult->seqHotLoops);
  this->seqRemarks465   = new String (disEMBLProcessResult->seqRemarks465);
    
  this->probLoopCoils   = new TListE <double> (disEMBLProcessResult->probLoopCoils);
  this->probHotLoops    = new TListE <double> (disEMBLProcessResult->probHotLoops);
  this->probRemarks465  = new TListE <double> (disEMBLProcessResult->probRemarks465);
  
  this->percentIDPLoopCoils   = 0;
  this->percentIDPHotLoops    = 0;
  this->percentIDPRemarks465  = 0;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
DisEMBLProcessResult::~DisEMBLProcessResult() {
  
  if (this->id)             delete this->id;
  if (this->sequence)       delete this->sequence;
  
  if (this->seqLoopCoils)   delete this->seqLoopCoils;
  if (this->seqHotLoops)    delete this->seqHotLoops;
  if (this->seqRemarks465)  delete this->seqRemarks465;
  
  if (this->probLoopCoils)  delete this->probLoopCoils;
  if (this->probHotLoops)   delete this->probHotLoops;
  if (this->probRemarks465) delete this->probRemarks465;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void DisEMBLProcessResult::Id(String* id) {
  
  if (id) this->id->In(id);
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void DisEMBLProcessResult::Sequence(String* sequence) {
  
  if (sequence) this->sequence->In(sequence);
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void DisEMBLProcessResult::SeqLoopCoils(String* seqLoopCoils) {
  
  if (seqLoopCoils) this->seqLoopCoils->In(seqLoopCoils);
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void DisEMBLProcessResult::SeqHotLoops(String* seqHotLoops) {
  
  if (seqHotLoops) this->seqHotLoops->In(seqHotLoops);
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void DisEMBLProcessResult::SeqRemarks465(String* seqRemarks465) {
  
  if (seqRemarks465) this->seqRemarks465->In(seqRemarks465);
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void DisEMBLProcessResult::ProbLoopCoils(TListE <double>* probLoopCoils) {
  
  if (probLoopCoils) *(this->probLoopCoils) = *(probLoopCoils);
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void DisEMBLProcessResult::ProbHotLoops(TListE <double>* probHotLoops) {
  
  if (probHotLoops) *(this->probHotLoops) = *(probHotLoops);
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void DisEMBLProcessResult::ProbRemarks465(TListE <double>* probRemarks465) {
  
  if (probRemarks465) *(this->probRemarks465) = *(probRemarks465);
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void DisEMBLProcessResult::PercentIDPLoopCoils(double percentIDPLoopCoils) {
  
  this->percentIDPLoopCoils = percentIDPLoopCoils;
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void DisEMBLProcessResult::PercentIDPHotLoops(double percentIDPHotLoops) {
  
  this->percentIDPHotLoops = percentIDPHotLoops;
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void DisEMBLProcessResult::PercentIDPRemarks465(double percentIDPRemarks465) {
  
  this->percentIDPRemarks465 = percentIDPRemarks465;
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
String* DisEMBLProcessResult::Id(void) {
  
  return this->id;
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
String* DisEMBLProcessResult::Sequence(void) {
  
  return this->sequence;
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
String* DisEMBLProcessResult::SeqLoopCoils(void) {
  
  return this->seqLoopCoils;
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
String* DisEMBLProcessResult::SeqHotLoops(void) {
  
  return this->seqHotLoops;
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
String* DisEMBLProcessResult::SeqRemarks465(void) {
  
  return this->seqRemarks465;
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
TListE <double>* DisEMBLProcessResult::ProbLoopCoils(void) {
  
  return this->probLoopCoils;
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
TListE <double>* DisEMBLProcessResult::ProbHotLoops(void) {
  
  return this->probHotLoops;
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
TListE <double>* DisEMBLProcessResult::ProbRemarks465(void) {
  
  return this->probRemarks465;
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
double DisEMBLProcessResult::PercentIDPLoopCoils(void) {
  
  return this->percentIDPLoopCoils;
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
double DisEMBLProcessResult::PercentIDPHotLoops(void) {
  
  return this->percentIDPHotLoops;
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
double DisEMBLProcessResult::PercentIDPRemarks465(void) {
  
  return this->percentIDPRemarks465;
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void DisEMBLProcessResult::IdInput(char* text) {
  
  if (text) {
    this->id->In(text + 1);
    this->id->Trim();
  }
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void DisEMBLProcessResult::SequenceInput(char* text) {
  
  if (text) {
    this->sequence->In(text + 1);
    this->sequence->Trim();
  }
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void DisEMBLProcessResult::SeqLoopCoilsInput(char* text) {
  
  if (text) {
    this->seqLoopCoils->In(text + 1);
    this->seqLoopCoils->Trim();
  }
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void DisEMBLProcessResult::SeqHotLoopsInput(char* text) {
  
  if (text) {
    this->seqHotLoops->In(text + 1);
    this->seqHotLoops->Trim();
  }
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void DisEMBLProcessResult::SeqRemarks465Input(char* text) {
  
  if (text) {
    this->seqRemarks465->In(text + 1);
    this->seqRemarks465->Trim();
  }
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void DisEMBLProcessResult::ProbLoopCoilsInput(char* text) {
  
  this->probLoopCoils->Clear();
  if (text) this->SplitColumn(text + 1, this->probLoopCoils, ",\n");
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void DisEMBLProcessResult::ProbHotLoopsInput(char* text) {
  
  this->probHotLoops->Clear();
  if (text) this->SplitColumn(text + 1, this->probHotLoops, ",\n");
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void DisEMBLProcessResult::ProbRemarks465Input(char* text) {
  
  this->probRemarks465->Clear();
  if (text) this->SplitColumn(text + 1, this->probRemarks465, ",\n");
    
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
double DisEMBLProcessResult::ComputePercentIDPLoopCoils(void) {
  
  double percentIDP = 0;
  
  for (int i = 0; i < this->seqLoopCoils->Length(); i++)
    if ((((int)this->seqLoopCoils->Out()[i]) >= 65) && (((int)this->seqLoopCoils->Out()[i]) <= 90))
      percentIDP++;
  
  percentIDP = (percentIDP * 100) / (double)this->seqLoopCoils->Length();
  
  return percentIDP;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
double DisEMBLProcessResult::ComputePercentIDPHotLoops(void) {
  
  double percentIDP = 0;
  
  for (int i = 0; i < this->seqHotLoops->Length(); i++)
    if ((((int)this->seqHotLoops->Out()[i]) >= 65) && (((int)this->seqHotLoops->Out()[i]) <= 90))
      percentIDP++;
  
  percentIDP = (percentIDP * 100) / (double)this->seqHotLoops->Length();
  
  return percentIDP;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
double DisEMBLProcessResult::ComputePercentIDPRemarks465(void) {
  
  double percentIDP = 0;
  
  for (int i = 0; i < this->seqRemarks465->Length(); i++)
    if ((((int)this->seqRemarks465->Out()[i]) >= 65) && (((int)this->seqRemarks465->Out()[i]) <= 90))
      percentIDP++;
  
  percentIDP = (percentIDP * 100) / (double)this->seqRemarks465->Length();
  
  return percentIDP;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
bool DisEMBLProcessResult::SplitColumn(char* buffer, TListE <String>* columns, char* characters) {

  if (!buffer || !columns || !characters) return false;

  char *part = strtok(buffer, characters);

  while (part) {
    String* cell = new String(part);
    cell->Trim();
    columns->Add(cell);
    part = strtok(NULL, characters);
  }

  return true;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
bool DisEMBLProcessResult::SplitColumn(char* buffer, TListE <String>* columns, const char* characters) {

  if (!buffer || !columns || !characters) return false;

  char *part = strtok(buffer, characters);

  while (part) {
    String* cell = new String(part);
    cell->Trim();
    columns->Add(cell);
    part = strtok(NULL, characters);
  }

  return true;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
bool DisEMBLProcessResult::SplitColumn(char* buffer, TListE <double>* columns, char* characters) {

  if (!buffer || !columns || !characters) return false;

  char *part = strtok(buffer, characters);

  while (part) {
    double* cell = new double;
    *cell = atof(part);
    columns->Add(cell);
    part = strtok(NULL, characters);
  }

  return true;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
bool DisEMBLProcessResult::SplitColumn(char* buffer, TListE <double>* columns, const char* characters) {

  if (!buffer || !columns || !characters) return false;

  char *part = strtok(buffer, characters);

  while (part) {
    double* cell = new double;
    *cell = atof(part);
    columns->Add(cell);
    part = strtok(NULL, characters);
  }

  return true;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
